package se.perp.c4.model;

import se.perp.c4.model.Territory.ETerritory;
import static se.perp.c4.model.Territory.ETerritory.*;
import static se.perp.c4.model.Territory.Type.*;

class TerritoryFactory {

    public static Territory create(ETerritory which) {
        Territory r = new Territory();
        r.capacity = 2;
        r.type = NORMAL;
        r.which = which;
        switch (which) {
            case SHIRE:
                r.type = HOME;
                r.capacity = 4;
                r.lightNeighbors = new ETerritory[]{ARTHEDAIN, CARDOLAN};
                r.adjacent = r.lightNeighbors;
                break;
            case ARTHEDAIN:
                r.darkNeighbors = new ETerritory[]{SHIRE};
                r.lightNeighbors = new ETerritory[]{RHUDAUR, EREGION};
                r.sidewaysNeighbors = new ETerritory[]{CARDOLAN};
                r.adjacent = new ETerritory[] {SHIRE, RHUDAUR, EREGION, CARDOLAN};
                break;
            case CARDOLAN:
                r.darkNeighbors = new ETerritory[]{SHIRE};
                r.lightNeighbors = new ETerritory[]{EREGION, ENEDWAITH};
                r.sidewaysNeighbors = new ETerritory[]{ARTHEDAIN};
                r.adjacent = new ETerritory[] {SHIRE, ENEDWAITH, EREGION, ARTHEDAIN};
                break;
            case RHUDAUR:
                r.darkNeighbors = new ETerritory[]{ARTHEDAIN};
                r.lightNeighbors = new ETerritory[]{HIGHPASS, MISTYMTS};
                r.sidewaysNeighbors = new ETerritory[]{EREGION};
                r.adjacent = new ETerritory[]{HIGHPASS, ARTHEDAIN, MISTYMTS, EREGION};
                break;
            case EREGION:
                r.darkNeighbors = new ETerritory[]{ARTHEDAIN, CARDOLAN};
                r.lightNeighbors = new ETerritory[]{MISTYMTS, MORIA, FANGORN};
                r.sidewaysNeighbors = new ETerritory[]{RHUDAUR, ENEDWAITH};
                r.adjacent = new ETerritory[]{ARTHEDAIN, CARDOLAN, RHUDAUR, ENEDWAITH, MISTYMTS, MORIA};
                break;
            case ENEDWAITH:
                r.darkNeighbors = new ETerritory[]{CARDOLAN};
                r.lightNeighbors = new ETerritory[]{MORIA, GAPOFROHAN};
                r.sidewaysNeighbors = new ETerritory[]{EREGION};
                r.adjacent = new ETerritory[] {MORIA, GAPOFROHAN, CARDOLAN, EREGION};
                break;

            case HIGHPASS:
                r.type = MOUNTAIN;
                r.capacity = 1;
                r.lightNeighbors = new ETerritory[]{MIRKWOOD};
                r.darkNeighbors = new ETerritory[]{RHUDAUR};
                r.adjacent = new ETerritory[]{MIRKWOOD, RHUDAUR};
                break;
            case MISTYMTS:
                r.type = MOUNTAIN;
                r.capacity = 1;
                r.lightNeighbors = new ETerritory[]{MIRKWOOD, FANGORN};
                r.darkNeighbors = new ETerritory[]{RHUDAUR, EREGION};
                r.adjacent = new ETerritory[]{MIRKWOOD, FANGORN, EREGION, RHUDAUR};
                break;
            case MORIA:
                r.type = MOUNTAIN;
                r.capacity = 1;
                r.lightNeighbors = new ETerritory[]{FANGORN, ROHAN};
                r.darkNeighbors = new ETerritory[]{EREGION, ENEDWAITH};
                r.adjacent = new ETerritory[] {FANGORN, ROHAN, ENEDWAITH, EREGION};
                break;
            case GAPOFROHAN:
                r.type = MOUNTAIN;
                r.capacity = 1;
                r.lightNeighbors = new ETerritory[]{ROHAN};
                r.darkNeighbors = new ETerritory[]{ENEDWAITH};
                r.adjacent = new ETerritory[]{ROHAN, ENEDWAITH};
                break;

            case MIRKWOOD:
                r.lightNeighbors = new ETerritory[]{DAGORLAD, FANGORN};
                r.darkNeighbors = new ETerritory[]{HIGHPASS, MISTYMTS};
                r.sidewaysNeighbors = new ETerritory[]{FANGORN};
                r.adjacent = new ETerritory[] {DAGORLAD, FANGORN, MISTYMTS, HIGHPASS};
                break;
            case FANGORN:
                r.lightNeighbors = new ETerritory[]{DAGORLAD, GONDOR, ROHAN};
                r.darkNeighbors = new ETerritory[]{MORIA, MISTYMTS};
                r.sidewaysNeighbors = new ETerritory[]{ROHAN, MIRKWOOD};
                r.adjacent = new ETerritory[]{MIRKWOOD, DAGORLAD, GONDOR, ROHAN, MORIA, MISTYMTS};
                break;
            case ROHAN:
                r.lightNeighbors = new ETerritory[]{GONDOR};
                r.darkNeighbors = new ETerritory[]{GAPOFROHAN, MORIA};
                r.sidewaysNeighbors = new ETerritory[]{FANGORN};
                r.adjacent = new ETerritory[] {FANGORN, GONDOR, GAPOFROHAN, MORIA};
                break;
            case DAGORLAD:
                r.lightNeighbors = new ETerritory[]{MORDOR};
                r.darkNeighbors = new ETerritory[]{MIRKWOOD, FANGORN};
                r.sidewaysNeighbors = new ETerritory[]{GONDOR};
                r.adjacent = new ETerritory[]{MIRKWOOD, FANGORN, GONDOR, MORDOR};
                break;
            case GONDOR:
                r.lightNeighbors = new ETerritory[]{MORDOR};
                r.darkNeighbors = new ETerritory[]{ROHAN, FANGORN};
                r.sidewaysNeighbors = new ETerritory[]{DAGORLAD};
                r.adjacent = new ETerritory[] {FANGORN, ROHAN, DAGORLAD, MORDOR};
                break;
            case MORDOR:
                r.capacity = 4;
                r.type = HOME;
                r.darkNeighbors = new ETerritory[]{DAGORLAD, GONDOR};
                r.adjacent = r.darkNeighbors;
                break;
            default:
                throw new Error("This should not happen.");
        }
        return r;
    }
}
